/**
 * @package: BrickCAD
 * @className: SideView.java
 * @package: default
 * @author: Sean O'Brien, Jack, Lester Tam, Erik Telstad
 * @date_created: November 16, 2009
 * @last_motified: November 16, 2009
 * 
 * 
 * 
 */


import java.util.Observable;



public class SideView extends BrickView {

	private static final long serialVersionUID = 1L;
	private static String title = "Side View";
	static int openFrameCount = 0;
	static final int xOffset = 200, yOffset = 10;
	
	private BrickImagePanel sideImagePanel;

	/**
	 * @param theModel
	 */
	public SideView(Brick theModel) {
		super(theModel);
		setTitle(title);
		openFrameCount++;
		setSize(FRAME_WIDTH, FRAME_HEIGHT);
		this.setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
		sideImagePanel = new BrickImagePanel(this.getWidth(), this.getHeight(), 
										model.getWidth(), model.getHeight());

		add(sideImagePanel);
		pack();
	}
	
	/* (non-Javadoc)
	 * @see BrickView#update(java.util.Observable, java.lang.Object)
	 */
	@Override
	public void update(Observable arg0, Object o) {
		model = (Brick) arg0;
		if( (sideImagePanel.getBrickWidth() != model.getWidth()) ||
				(sideImagePanel.getBrickHeight() != model.getHeight()) ) {
			
			//System.out.println("Updating SideView #" + openFrameCount);

			//System.out.print("Brick width: " + model.getWidth());
			sideImagePanel.setBrickWidth(model.getWidth());
			
			//System.out.print(" Brick height: " + model.getHeight());
			sideImagePanel.setBrickHeight(model.getHeight());

			sideImagePanel.repaint();
		}
	}
}
